//
//  BaseTableviewControll.swift
//  sinaweibo
//
//  Created by icefs2 on 15/11/8.
//  Copyright © 2015年 icefs2. All rights reserved.
//

import UIKit

class BaseTableviewControll: UITableViewController, VIsitorLoginViewDelegate {
    
    var userLogin = UserAccoutviewModel().userlogin
    
    var vistorloginview: VIsitorLoginView?
    
    
  
    
    override func loadView() {
        
        userLogin ? super.loadView() : loadvistorloginview()
        
    }
    
    
    private func loadvistorloginview() {
        vistorloginview = NSBundle.mainBundle().loadNibNamed("VIsitorLoginView", owner: nil, options: nil).last as? VIsitorLoginView
        vistorloginview?.delegate = self
        view = vistorloginview
        self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "VIsitorregistedViewDidSelected")
        self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登陆", style: UIBarButtonItemStyle.Plain, target: self, action: "VIsitorLoginViewDidSelected")
    }
    
//        var vistorloginview: VIsitorLoginView?
//    //可以添加用户是否登陆的标记
//        override func loadView() {
//            vistorloginview = NSBundle.mainBundle().loadNibNamed("VIsitorLoginView", owner: nil, options: nil).last as? VIsitorLoginView
//                    vistorloginview?.delegate = self
//                    view = vistorloginview
//                    self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "VIsitorregistedViewDidSelected")
//                    self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登陆", style: UIBarButtonItemStyle.Plain, target: self, action: "VIsitorLoginViewDidSelected")
//        }
//    
    func VIsitorLoginViewDidSelected() {
        print("login")
       let oauth = OAuthViewController()
         let nav = UINavigationController(rootViewController: oauth)
        presentViewController(nav, animated: true, completion: nil)
        }
    func VIsitorregistedViewDidSelected() {
        print("regist")
    }
    
}
